package com.jacobson.huobi.mvp.model

import com.alibaba.fastjson.JSONObject
import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.framework.repository.IRepositoryManager
import com.jacobson.core.mvp.BaseModel
import com.jacobson.huobi.api.LoginAndRegisterApi
import com.jacobson.huobi.api.MeInfoApi
import com.jacobson.huobi.entities.UpdateInfo
import com.jacobson.huobi.entities.response.CommonResponse
import com.jacobson.huobi.mvp.contract.MeContract
import io.reactivex.Observable
import javax.inject.Inject

@ActivityScope
class MeModel @Inject constructor(
    repositoryManager: IRepositoryManager
) : BaseModel(repositoryManager), MeContract.Model {

    private val loginAndRegisterApi =
        repositoryManager.obtainRetrofitService(LoginAndRegisterApi::class.java)

    private val meInfoApi =
        repositoryManager.obtainRetrofitService(MeInfoApi::class.java)


    override fun refreshToken(): Observable<CommonResponse<JSONObject>> {
        return loginAndRegisterApi.refreshToken()
    }
    override fun loadNoticeLatest(): Observable<CommonResponse<List<JSONObject>>> {
        return meInfoApi.loadNoticeLatest()
    }
    override fun loadUpdateInfo():Observable<CommonResponse<UpdateInfo>>{
        return meInfoApi.loadUpdateInfo();
    }
}